﻿namespace 特性.Attr
{
    public class CustomerValidateAttribute : Attribute
    {
        private int maxlength;
        private int minlength;
        public string msg = "验证失败";

        public CustomerValidateAttribute(int maxlength, int minlength)
        {
            this.maxlength = maxlength;
            this.minlength = minlength;
        }

        public bool Validate(object value)
        {
            if (value == null)
            {
                return false;
            }
            else if (value.ToString().Length < minlength)
            {
                return false;
            }
            else if (value.ToString().Length > maxlength)
            {
                return false;
            }
            return true;
        }
    }
}